// index.js
var network = require("../../utils/network.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    indicatordots: "true",
    autoplay: "true",
    interval: "3000",
    duration: "1000",
    banner: [],
    category: [],
  },

  //banner
  banner: function(){
    let that = this;
    let URL  = network.server() + 'banner/list';
    let Params = {};
    let Method = 'GET';
    let Message = '';
    network.requestGet(URL, Params, Method, Message, function (res) {
      //console.log('轮播---', res)
      if (res.code == 0) {
        let banner = res.data.list;
        that.setData({
          banner: banner
        })
      }
    }, function () {})
  },

  //分类列表
  category: function () {
    let that = this;
    let URL = network.server() + 'service/index';
    let Params = {};
    let Method = 'GET';
    let Message = '';
    network.requestGet(URL, Params, Method, Message, function (res) {
      //console.log('分类列表---', res)
      if (res.code == 0) {
        let category = res.data.list;
        that.setData({
          category: category,
        })
      }
    }, function () {})
  },

  //分类详情
  categoryDetail: function (e) {
    let that = this;
    let service_name = e.currentTarget.dataset.service_name;
    let service_id = e.currentTarget.dataset.service_id;
    wx.navigateTo({
      url: '../categoryDetail/index?service_name=' + service_name + '&service_id=' + service_id,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.banner();
    this.category();
  },
  /**
     * 用户点击右上角分享
     */
  onShareAppMessage: function () {

  }
})